<%--
  Created by IntelliJ IDEA.
  User: zzz
  Date: 2020/2/5
  Time: 15:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
</head>
<body>
<div class="head">
    <div class="wrapper clearfix">
        <div class="clearfix" id="top">
            <h1 class="fl"><a href="${APP_PATH}/toPortal"><img src="${APP_PATH}/portal/img/logo.png"/></a></h1>
            <div class="fr clearfix" id="top1">
                <p id="user" class="fl">
                </p>
                <form action="${APP_PATH}/goods/findGoods" method="get" class="fl">
                    <input type="text" name="likeName" placeholder="热门搜索：干花" />
                    <input type="submit" value=""/>
                </form>
                <div class="btn fl clearfix">
                    <a href="${APP_PATH}/${sessionScope.user == null?"toPortalLogin":"toUser"}"><img src="${APP_PATH}/portal/img/grzx.png"/></a>
                    <a href="javascript:;" class="er1"><img src="${APP_PATH}/portal/img/ewm.png"/></a>
                    <a href="${APP_PATH}/${sessionScope.user == null?"toPortalLogin":"toTrolley"}"><img src="${APP_PATH}/portal/img/gwc.png"/></a>
                    <p><a href="#"><img src="${APP_PATH}/portal/img/smewm.png"/></a></p>
                </div>
            </div>
        </div>
        <ul class="clearfix" id="bott">
        </ul>
    </div>
</div>
</body>
</html>
<script src="${APP_PATH}/portal/js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
<script>
    $(function () {
        getTopInfo();

        var userContent = "";
        if(${sessionScope.user == null}){
            userContent += '<a href="${APP_PATH}/toPortalLogin" id="login">登录</a>';
            userContent += '<a href="${APP_PATH}/toRegister" id="reg">注册</a>';
        }else{
            userContent += '<img style="width:35px; float: left; margin-top:-10px;" src="${APP_PATH}/${sessionScope.user.uface == null?"portal/img/tx.png" : sessionScope.user.uface}"><a href="${APP_PATH}/toUser" style="float:left;">【${sessionScope.user.unick}】</a>';
            userContent += '<span style="float:left;">|</span><a style="float:left;" href="${APP_PATH}/user/exit" id="reg">注销</a>';
        }
        $("#user").html(userContent);
    });
    function getTopInfo() {
        $.ajax({
            url : "${APP_PATH}/goods/getTopInfo",
            method : "GET",
            success : function (result) {
                if(result.success){
                    var kindsList = result.data.kindsList;
                    var topInfo = "";
                    topInfo += '<li><a href="${APP_PATH}/toPortal">首页</a></li>';
                    topInfo += '<li> <a href="${APP_PATH}/toAllGoods">所有商品</a> </li>';
                    for(var i = 0 ; i < kindsList.length ; i ++){
                        if(kindsList[i].style == 1){
                                topInfo +='<li>';
                                topInfo +='<a href="${APP_PATH}/toKindsGoods?kid='+kindsList[i].kid+'">'+kindsList[i].kname+'</a>';
                                topInfo +='<div class="sList2">';
                                topInfo +='<div class="clearfix">';
                             var kindsTypeList = result.data.kindsTypeMap[kindsList[i].kid];
                            for(var j = 0; j < kindsTypeList.length ; j ++){
                                    topInfo +='<a href="${APP_PATH}/toKindsTypeGoods?kid='+kindsList[i].kid+'&ktid='+kindsTypeList[j].ktid+'">'+kindsTypeList[j].ktname+'</a>';
                            }
                                topInfo +='</div>';
                                topInfo +='</div>';
                                topInfo += '</li>';
                        }else{
                            topInfo +='<li><a href="${APP_PATH}/toKindsGoods2?kid='+kindsList[i].kid+'">'+kindsList[i].kname+'</a></li>';
                        }
                    }
                    $("#bott").html(topInfo);
                    topRender();
                }
            }
        });
    }
</script>